package com.google.android.material.textfield;

import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.PorterDuff.Mode;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.Typeface;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.DrawableContainer;
import android.graphics.drawable.GradientDrawable;
import android.os.Build.VERSION;
import android.os.Parcel;
import android.os.Parcelable;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.text.method.PasswordTransformationMethod;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStructure;
import android.view.accessibility.AccessibilityEvent;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
import androidx.annotation.ColorRes;
import androidx.annotation.DimenRes;
import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
import androidx.annotation.StyleRes;
import androidx.annotation.VisibleForTesting;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.core.view.ViewCompat;
import androidx.core.widget.TextViewCompat;
import androidx.customview.view.AbsSavedState;
import com.google.android.material.internal.CheckableImageButton;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import o.aqu.c;
import o.aqu.d;
import o.aqu.f;
import o.aqu.h;
import o.aqu.i;
import o.aqu.j;
import o.aqu.n;
import o.aqv;
import o.ar;
import o.arw;
import o.arx;
import o.ary;
import o.asa;
import o.ash;
import o.asv;
import o.asy;
import o.bx;
import o.cl;
import o.cw;
import o.fo;
import o.gg;
import o.hc;
import o.in;

public class TextInputLayout extends LinearLayout {
    private TextView ʻ;
    private int ʻॱ;
    private boolean ʼ;
    private final int ʼॱ;
    private final asy ʽ;
    private int ʽॱ;
    private float ʾ;
    private float ʿ;
    private float ˈ;
    private final Rect ˉ;
    EditText ˊ;
    private Drawable ˊˊ;
    @ColorInt
    private int ˊˋ;
    private boolean ˊॱ;
    private final int ˊᐝ;
    private final FrameLayout ˋ;
    @ColorInt
    private int ˋˊ;
    private boolean ˋˋ;
    private final int ˋॱ;
    private Drawable ˋᐝ;
    private Typeface ˌ;
    private CharSequence ˍ;
    final ary ˎ;
    private final RectF ˎˎ;
    private boolean ˎˏ;
    private CharSequence ˏ;
    private Drawable ˏˎ;
    private CheckableImageButton ˏˏ;
    private boolean ˏॱ;
    private Drawable ˑ;
    private GradientDrawable ͺ;
    private ColorStateList ͺॱ;
    private boolean ـ;
    boolean ॱ;
    private ColorStateList ॱʻ;
    private Mode ॱʼ;
    private boolean ॱʽ;
    private CharSequence ॱˊ;
    private final int ॱˋ;
    private float ॱˎ;
    private ColorStateList ॱͺ;
    private int ॱॱ;
    private final int ॱᐝ;
    private final int ᐝ;
    private boolean ᐝˊ;
    @ColorInt
    private int ᐝˋ;
    private final int ᐝॱ;
    @ColorInt
    private final int ᐝᐝ;
    @ColorInt
    private final int ᐧ;
    @ColorInt
    private final int ᐨ;
    private boolean ᶥ;
    private boolean ㆍ;
    private boolean ꓸ;
    private ValueAnimator ꜞ;
    private boolean ꜟ;

    @Retention(RetentionPolicy.SOURCE)
    public @interface BoxBackgroundMode {
    }

    static class SavedState extends AbsSavedState {
        public static final Creator<SavedState> CREATOR = new ClassLoaderCreator<SavedState>() {
            public /* synthetic */ Object createFromParcel(Parcel parcel) {
                return ˋ(parcel);
            }

            public /* synthetic */ Object createFromParcel(Parcel parcel, ClassLoader classLoader) {
                return ˏ(parcel, classLoader);
            }

            public /* synthetic */ Object[] newArray(int i) {
                return ˋ(i);
            }

            public SavedState ˏ(Parcel parcel, ClassLoader classLoader) {
                return new SavedState(parcel, classLoader);
            }

            public SavedState ˋ(Parcel parcel) {
                return new SavedState(parcel, null);
            }

            public SavedState[] ˋ(int i) {
                return new SavedState[i];
            }
        };
        CharSequence ˏ;
        boolean ॱ;

        SavedState(Parcelable parcelable) {
            super(parcelable);
        }

        SavedState(Parcel parcel, ClassLoader classLoader) {
            super(parcel, classLoader);
            this.ˏ = (CharSequence) TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(parcel);
            this.ॱ = parcel.readInt() == 1;
        }

        public void writeToParcel(Parcel parcel, int i) {
            super.writeToParcel(parcel, i);
            TextUtils.writeToParcel(this.ˏ, parcel, i);
            parcel.writeInt(this.ॱ ? 1 : 0);
        }

        public String toString() {
            return "TextInputLayout.SavedState{" + Integer.toHexString(System.identityHashCode(this)) + " error=" + this.ˏ + "}";
        }
    }

    public static class b extends hc {
        private final TextInputLayout ˏ;

        public b(TextInputLayout textInputLayout) {
            this.ˏ = textInputLayout;
        }

        public void ˋ(View view, in inVar) {
            boolean z;
            boolean z2;
            boolean z3;
            boolean z4;
            boolean z5 = false;
            super.ˋ(view, inVar);
            EditText ˎ = this.ˏ.ˎ();
            CharSequence text = ˎ != null ? ˎ.getText() : null;
            CharSequence ॱ = this.ˏ.ॱ();
            CharSequence ᐝ = this.ˏ.ᐝ();
            CharSequence ˋ = this.ˏ.ˋ();
            if (TextUtils.isEmpty(text)) {
                z = false;
            } else {
                z = true;
            }
            if (TextUtils.isEmpty(ॱ)) {
                z2 = false;
            } else {
                z2 = true;
            }
            if (TextUtils.isEmpty(ᐝ)) {
                z3 = false;
            } else {
                z3 = true;
            }
            if (z3 || !TextUtils.isEmpty(ˋ)) {
                z4 = true;
            } else {
                z4 = false;
            }
            if (z) {
                inVar.ˋ(text);
            } else if (z2) {
                inVar.ˋ(ॱ);
            }
            if (z2) {
                inVar.ʽ(ॱ);
                if (!z && z2) {
                    z5 = true;
                }
                inVar.ॱˋ(z5);
            }
            if (z4) {
                if (z3) {
                    text = ᐝ;
                } else {
                    text = ˋ;
                }
                inVar.ᐝ(text);
                inVar.ॱˊ(true);
            }
        }

        public void ˊ(View view, AccessibilityEvent accessibilityEvent) {
            super.ˊ(view, accessibilityEvent);
            EditText ˎ = this.ˏ.ˎ();
            CharSequence text = ˎ != null ? ˎ.getText() : null;
            if (TextUtils.isEmpty(text)) {
                text = this.ˏ.ॱ();
            }
            if (!TextUtils.isEmpty(text)) {
                accessibilityEvent.getText().add(text);
            }
        }
    }

    public TextInputLayout(Context context) {
        this(context, null);
    }

    public TextInputLayout(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, d.ॱᐝ);
    }

    public TextInputLayout(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.ʽ = new asy(this);
        this.ˉ = new Rect();
        this.ˎˎ = new RectF();
        this.ˎ = new ary(this);
        setOrientation(1);
        setWillNotDraw(false);
        setAddStatesFromChildren(true);
        this.ˋ = new FrameLayout(context);
        this.ˋ.setAddStatesFromChildren(true);
        addView(this.ˋ);
        this.ˎ.ˋ(aqv.ˊ);
        this.ˎ.ˊ(aqv.ˊ);
        this.ˎ.ॱ(8388659);
        cw ˏ = asa.ˏ(context, attributeSet, n.ᐝـ, i, f.ॱˊ, new int[0]);
        this.ˊॱ = ˏ.ˋ(n.ᐝꜞ, true);
        setHint(ˏ.ˊ(n.ᐝᐨ));
        this.ㆍ = ˏ.ˋ(n.ᐝㆍ, true);
        this.ॱˋ = context.getResources().getDimensionPixelOffset(c.ʻॱ);
        this.ᐝॱ = context.getResources().getDimensionPixelOffset(c.ʽॱ);
        this.ॱᐝ = ˏ.ˊ(n.ᐨˋ, 0);
        this.ॱˎ = ˏ.ˏ(n.ᐩ, 0.0f);
        this.ˈ = ˏ.ˏ(n.ᑊ, 0.0f);
        this.ʾ = ˏ.ˏ(n.ᕀ, 0.0f);
        this.ʿ = ˏ.ˏ(n.ᐨᐝ, 0.0f);
        this.ˊˋ = ˏ.ˋ(n.ᵔॱ, 0);
        this.ᐝˋ = ˏ.ˋ(n.ᵕ, 0);
        this.ʼॱ = context.getResources().getDimensionPixelSize(c.ˈ);
        this.ˊᐝ = context.getResources().getDimensionPixelSize(c.ʿ);
        this.ʽॱ = this.ʼॱ;
        setBoxBackgroundMode(ˏ.ॱ(n.ᐨˊ, 0));
        if (ˏ.ᐝ(n.ᐝˌ)) {
            ColorStateList ॱ = ˏ.ॱ(n.ᐝˌ);
            this.ॱͺ = ॱ;
            this.ॱʻ = ॱ;
        }
        this.ᐧ = fo.ˋ(context, o.aqu.b.ʼ);
        this.ᐝᐝ = fo.ˋ(context, o.aqu.b.ॱˊ);
        this.ᐨ = fo.ˋ(context, o.aqu.b.ˋॱ);
        if (ˏ.ॱॱ(n.ᐝꜟ, -1) != -1) {
            setHintTextAppearance(ˏ.ॱॱ(n.ᐝꜟ, 0));
        }
        int ॱॱ = ˏ.ॱॱ(n.ᐝᶥ, 0);
        boolean ˋ = ˏ.ˋ(n.ᐝˑ, false);
        int ॱॱ2 = ˏ.ॱॱ(n.ᐝꞌ, 0);
        boolean ˋ2 = ˏ.ˋ(n.ᐝﾞ, false);
        CharSequence ˊ = ˏ.ˊ(n.ᐝꓸ);
        boolean ˋ3 = ˏ.ˋ(n.ᐝﹳ, false);
        setCounterMaxLength(ˏ.ॱ(n.ᐠ, -1));
        this.ˋॱ = ˏ.ॱॱ(n.ᐝᐧ, 0);
        this.ᐝ = ˏ.ॱॱ(n.ᐝﾟ, 0);
        this.ˋˋ = ˏ.ˋ(n.ᐣ, false);
        this.ˋᐝ = ˏ.ˋ(n.ᐧᐝ);
        this.ˍ = ˏ.ˊ(n.ᐧˎ);
        if (ˏ.ᐝ(n.ᐧˋ)) {
            this.ـ = true;
            this.ͺॱ = ˏ.ॱ(n.ᐧˋ);
        }
        if (ˏ.ᐝ(n.ᐧˊ)) {
            this.ॱʽ = true;
            this.ॱʼ = ash.ˏ(ˏ.ॱ(n.ᐧˊ, -1), null);
        }
        ˏ.ॱ();
        setHelperTextEnabled(ˋ2);
        setHelperText(ˊ);
        setHelperTextTextAppearance(ॱॱ2);
        setErrorEnabled(ˋ);
        setErrorTextAppearance(ॱॱ);
        setCounterEnabled(ˋ3);
        ˈ();
        ViewCompat.setImportantForAccessibility(this, 2);
    }

    public void addView(View view, int i, LayoutParams layoutParams) {
        if (view instanceof EditText) {
            LayoutParams layoutParams2 = new FrameLayout.LayoutParams(layoutParams);
            layoutParams2.gravity = (layoutParams2.gravity & -113) | 16;
            this.ˋ.addView(view, layoutParams2);
            this.ˋ.setLayoutParams(layoutParams);
            ˏॱ();
            ˊ((EditText) view);
            return;
        }
        super.addView(view, i, layoutParams);
    }

    @NonNull
    private Drawable ʻ() {
        if (this.ʻॱ == 1 || this.ʻॱ == 2) {
            return this.ͺ;
        }
        throw new IllegalStateException();
    }

    public void setBoxBackgroundMode(int i) {
        if (i != this.ʻॱ) {
            this.ʻॱ = i;
            ॱॱ();
        }
    }

    private void ॱॱ() {
        ॱˊ();
        if (this.ʻॱ != 0) {
            ˏॱ();
        }
        ˊॱ();
    }

    private void ॱˊ() {
        if (this.ʻॱ == 0) {
            this.ͺ = null;
        } else if (this.ʻॱ == 2 && this.ˊॱ && !(this.ͺ instanceof asv)) {
            this.ͺ = new asv();
        } else if (!(this.ͺ instanceof GradientDrawable)) {
            this.ͺ = new GradientDrawable();
        }
    }

    public void setBoxStrokeColor(@ColorInt int i) {
        if (this.ᐝˋ != i) {
            this.ᐝˋ = i;
            ʼ();
        }
    }

    public void setBoxBackgroundColorResource(@ColorRes int i) {
        setBoxBackgroundColor(fo.ˋ(getContext(), i));
    }

    public void setBoxBackgroundColor(@ColorInt int i) {
        if (this.ˊˋ != i) {
            this.ˊˋ = i;
            ᐝॱ();
        }
    }

    public void setBoxCornerRadiiResources(@DimenRes int i, @DimenRes int i2, @DimenRes int i3, @DimenRes int i4) {
        setBoxCornerRadii(getContext().getResources().getDimension(i), getContext().getResources().getDimension(i2), getContext().getResources().getDimension(i3), getContext().getResources().getDimension(i4));
    }

    public void setBoxCornerRadii(float f, float f2, float f3, float f4) {
        if (this.ॱˎ != f || this.ˈ != f2 || this.ʾ != f4 || this.ʿ != f3) {
            this.ॱˎ = f;
            this.ˈ = f2;
            this.ʾ = f4;
            this.ʿ = f3;
            ᐝॱ();
        }
    }

    private float[] ˋॱ() {
        if (ash.ˊ(this)) {
            return new float[]{this.ˈ, this.ˈ, this.ॱˎ, this.ॱˎ, this.ʿ, this.ʿ, this.ʾ, this.ʾ};
        }
        return new float[]{this.ॱˎ, this.ॱˎ, this.ˈ, this.ˈ, this.ʾ, this.ʾ, this.ʿ, this.ʿ};
    }

    public void setTypeface(@Nullable Typeface typeface) {
        if (typeface != this.ˌ) {
            this.ˌ = typeface;
            this.ˎ.ˎ(typeface);
            this.ʽ.ॱ(typeface);
            if (this.ʻ != null) {
                this.ʻ.setTypeface(typeface);
            }
        }
    }

    public void dispatchProvideAutofillStructure(ViewStructure viewStructure, int i) {
        if (this.ˏ == null || this.ˊ == null) {
            super.dispatchProvideAutofillStructure(viewStructure, i);
            return;
        }
        boolean z = this.ˏॱ;
        this.ˏॱ = false;
        CharSequence hint = this.ˊ.getHint();
        this.ˊ.setHint(this.ˏ);
        try {
            super.dispatchProvideAutofillStructure(viewStructure, i);
        } finally {
            this.ˊ.setHint(hint);
            this.ˏॱ = z;
        }
    }

    private void ˊ(EditText editText) {
        if (this.ˊ != null) {
            throw new IllegalArgumentException("We already have an EditText, can only have one");
        }
        if (!(editText instanceof TextInputEditText)) {
            Log.i("TextInputLayout", "EditText added is not a TextInputEditText. Please switch to using that class instead.");
        }
        this.ˊ = editText;
        ॱॱ();
        setTextInputAccessibilityDelegate(new b(this));
        if (!ʿ()) {
            this.ˎ.ˎ(this.ˊ.getTypeface());
        }
        this.ˎ.ˋ(this.ˊ.getTextSize());
        int gravity = this.ˊ.getGravity();
        this.ˎ.ॱ((gravity & -113) | 48);
        this.ˎ.ˎ(gravity);
        this.ˊ.addTextChangedListener(new TextWatcher(this) {
            final /* synthetic */ TextInputLayout ॱ;

            {
                this.ॱ = r1;
            }

            public void afterTextChanged(Editable editable) {
                this.ॱ.ॱ(!this.ॱ.ꓸ);
                if (this.ॱ.ॱ) {
                    this.ॱ.ˏ(editable.length());
                }
            }

            public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            }

            public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            }
        });
        if (this.ॱʻ == null) {
            this.ॱʻ = this.ˊ.getHintTextColors();
        }
        if (this.ˊॱ) {
            if (TextUtils.isEmpty(this.ॱˊ)) {
                this.ˏ = this.ˊ.getHint();
                setHint(this.ˏ);
                this.ˊ.setHint(null);
            }
            this.ˏॱ = true;
        }
        if (this.ʻ != null) {
            ˏ(this.ˊ.getText().length());
        }
        this.ʽ.ॱ();
        ʾ();
        ˏ(false, true);
    }

    private void ˏॱ() {
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.ˋ.getLayoutParams();
        int ॱˋ = ॱˋ();
        if (ॱˋ != layoutParams.topMargin) {
            layoutParams.topMargin = ॱˋ;
            this.ˋ.requestLayout();
        }
    }

    public void ॱ(boolean z) {
        ˏ(z, false);
    }

    private void ˏ(boolean z, boolean z2) {
        Object obj = 1;
        boolean isEnabled = isEnabled();
        Object obj2 = (this.ˊ == null || TextUtils.isEmpty(this.ˊ.getText())) ? null : 1;
        if (this.ˊ == null || !this.ˊ.hasFocus()) {
            obj = null;
        }
        boolean ʽ = this.ʽ.ʽ();
        if (this.ॱʻ != null) {
            this.ˎ.ˊ(this.ॱʻ);
            this.ˎ.ˋ(this.ॱʻ);
        }
        if (!isEnabled) {
            this.ˎ.ˊ(ColorStateList.valueOf(this.ᐝᐝ));
            this.ˎ.ˋ(ColorStateList.valueOf(this.ᐝᐝ));
        } else if (ʽ) {
            this.ˎ.ˊ(this.ʽ.ʼ());
        } else if (this.ʼ && this.ʻ != null) {
            this.ˎ.ˊ(this.ʻ.getTextColors());
        } else if (!(obj == null || this.ॱͺ == null)) {
            this.ˎ.ˊ(this.ॱͺ);
        }
        if (obj2 != null || (isEnabled() && (obj != null || ʽ))) {
            if (z2 || this.ᐝˊ) {
                ˎ(z);
            }
        } else if (z2 || !this.ᐝˊ) {
            ˏ(z);
        }
    }

    @Nullable
    public EditText ˎ() {
        return this.ˊ;
    }

    public void setHint(@Nullable CharSequence charSequence) {
        if (this.ˊॱ) {
            ˏ(charSequence);
            sendAccessibilityEvent(2048);
        }
    }

    private void ˏ(CharSequence charSequence) {
        if (!TextUtils.equals(charSequence, this.ॱˊ)) {
            this.ॱˊ = charSequence;
            this.ˎ.ˋ(charSequence);
            if (!this.ᐝˊ) {
                ˋˊ();
            }
        }
    }

    @Nullable
    public CharSequence ॱ() {
        return this.ˊॱ ? this.ॱˊ : null;
    }

    public void setHintEnabled(boolean z) {
        if (z != this.ˊॱ) {
            this.ˊॱ = z;
            if (this.ˊॱ) {
                CharSequence hint = this.ˊ.getHint();
                if (!TextUtils.isEmpty(hint)) {
                    if (TextUtils.isEmpty(this.ॱˊ)) {
                        setHint(hint);
                    }
                    this.ˊ.setHint(null);
                }
                this.ˏॱ = true;
            } else {
                this.ˏॱ = false;
                if (!TextUtils.isEmpty(this.ॱˊ) && TextUtils.isEmpty(this.ˊ.getHint())) {
                    this.ˊ.setHint(this.ॱˊ);
                }
                ˏ(null);
            }
            if (this.ˊ != null) {
                ˏॱ();
            }
        }
    }

    boolean ˏ() {
        return this.ˏॱ;
    }

    public void setHintTextAppearance(@StyleRes int i) {
        this.ˎ.ˊ(i);
        this.ॱͺ = this.ˎ.ʼ();
        if (this.ˊ != null) {
            ॱ(false);
            ˏॱ();
        }
    }

    public void setDefaultHintTextColor(@Nullable ColorStateList colorStateList) {
        this.ॱʻ = colorStateList;
        this.ॱͺ = colorStateList;
        if (this.ˊ != null) {
            ॱ(false);
        }
    }

    public void setErrorEnabled(boolean z) {
        this.ʽ.ˎ(z);
    }

    public void setErrorTextAppearance(@StyleRes int i) {
        this.ʽ.ॱ(i);
    }

    public void setErrorTextColor(@Nullable ColorStateList colorStateList) {
        this.ʽ.ˏ(colorStateList);
    }

    public void setHelperTextTextAppearance(@StyleRes int i) {
        this.ʽ.ˎ(i);
    }

    public void setHelperTextEnabled(boolean z) {
        this.ʽ.ˊ(z);
    }

    public void setHelperText(@Nullable CharSequence charSequence) {
        if (!TextUtils.isEmpty(charSequence)) {
            if (!ˊ()) {
                setHelperTextEnabled(true);
            }
            this.ʽ.ˏ(charSequence);
        } else if (ˊ()) {
            setHelperTextEnabled(false);
        }
    }

    public boolean ˊ() {
        return this.ʽ.ʻ();
    }

    public void setHelperTextColor(@Nullable ColorStateList colorStateList) {
        this.ʽ.ॱ(colorStateList);
    }

    public void setError(@Nullable CharSequence charSequence) {
        if (!this.ʽ.ˋ()) {
            if (!TextUtils.isEmpty(charSequence)) {
                setErrorEnabled(true);
            } else {
                return;
            }
        }
        if (TextUtils.isEmpty(charSequence)) {
            this.ʽ.ˎ();
        } else {
            this.ʽ.ˊ(charSequence);
        }
    }

    public void setCounterEnabled(boolean z) {
        if (this.ॱ != z) {
            if (z) {
                this.ʻ = new AppCompatTextView(getContext());
                this.ʻ.setId(j.ˋॱ);
                if (this.ˌ != null) {
                    this.ʻ.setTypeface(this.ˌ);
                }
                this.ʻ.setMaxLines(1);
                ˊ(this.ʻ, this.ˋॱ);
                this.ʽ.ॱ(this.ʻ, 2);
                if (this.ˊ == null) {
                    ˏ(0);
                } else {
                    ˏ(this.ˊ.getText().length());
                }
            } else {
                this.ʽ.ˋ(this.ʻ, 2);
                this.ʻ = null;
            }
            this.ॱ = z;
        }
    }

    public void setCounterMaxLength(int i) {
        if (this.ॱॱ != i) {
            if (i > 0) {
                this.ॱॱ = i;
            } else {
                this.ॱॱ = -1;
            }
            if (this.ॱ) {
                ˏ(this.ˊ == null ? 0 : this.ˊ.getText().length());
            }
        }
    }

    public void setEnabled(boolean z) {
        ˋ(this, z);
        super.setEnabled(z);
    }

    private static void ˋ(ViewGroup viewGroup, boolean z) {
        int childCount = viewGroup.getChildCount();
        for (int i = 0; i < childCount; i++) {
            View childAt = viewGroup.getChildAt(i);
            childAt.setEnabled(z);
            if (childAt instanceof ViewGroup) {
                ˋ((ViewGroup) childAt, z);
            }
        }
    }

    @Nullable
    CharSequence ˋ() {
        if (this.ॱ && this.ʼ && this.ʻ != null) {
            return this.ʻ.getContentDescription();
        }
        return null;
    }

    void ˏ(int i) {
        boolean z = this.ʼ;
        if (this.ॱॱ == -1) {
            this.ʻ.setText(String.valueOf(i));
            this.ʻ.setContentDescription(null);
            this.ʼ = false;
        } else {
            if (ViewCompat.ॱॱ(this.ʻ) == 1) {
                ViewCompat.ˋ(this.ʻ, 0);
            }
            this.ʼ = i > this.ॱॱ;
            if (z != this.ʼ) {
                ˊ(this.ʻ, this.ʼ ? this.ᐝ : this.ˋॱ);
                if (this.ʼ) {
                    ViewCompat.ˋ(this.ʻ, 1);
                }
            }
            this.ʻ.setText(getContext().getString(h.ॱ, new Object[]{Integer.valueOf(i), Integer.valueOf(this.ॱॱ)}));
            this.ʻ.setContentDescription(getContext().getString(h.ˎ, new Object[]{Integer.valueOf(i), Integer.valueOf(this.ॱॱ)}));
        }
        if (this.ˊ != null && z != this.ʼ) {
            ॱ(false);
            ʼ();
            ʽ();
        }
    }

    public void ˊ(TextView textView, @StyleRes int i) {
        Object obj = 1;
        try {
            TextViewCompat.ˎ(textView, i);
            if (VERSION.SDK_INT < 23 || textView.getTextColors().getDefaultColor() != -65281) {
                obj = null;
            }
        } catch (Exception e) {
        }
        if (obj != null) {
            TextViewCompat.ˎ(textView, f.ˊ);
            textView.setTextColor(fo.ˋ(getContext(), o.aqu.b.ˊ));
        }
    }

    private void ˊॱ() {
        if (this.ʻॱ != 0 && this.ͺ != null && this.ˊ != null && getRight() != 0) {
            int left = this.ˊ.getLeft();
            int ͺ = ͺ();
            int right = this.ˊ.getRight();
            int bottom = this.ˊ.getBottom() + this.ॱˋ;
            if (this.ʻॱ == 2) {
                left += this.ˊᐝ / 2;
                ͺ -= this.ˊᐝ / 2;
                right -= this.ˊᐝ / 2;
                bottom += this.ˊᐝ / 2;
            }
            this.ͺ.setBounds(left, ͺ, right, bottom);
            ᐝॱ();
            ॱˎ();
        }
    }

    private int ͺ() {
        if (this.ˊ == null) {
            return 0;
        }
        switch (this.ʻॱ) {
            case 1:
                return this.ˊ.getTop();
            case 2:
                return this.ˊ.getTop() + ॱˋ();
            default:
                return 0;
        }
    }

    private int ॱˋ() {
        if (!this.ˊॱ) {
            return 0;
        }
        switch (this.ʻॱ) {
            case 0:
            case 1:
                return (int) this.ˎ.ˎ();
            case 2:
                return (int) (this.ˎ.ˎ() / 2.0f);
            default:
                return 0;
        }
    }

    private int ʻॱ() {
        switch (this.ʻॱ) {
            case 1:
                return ʻ().getBounds().top + this.ॱᐝ;
            case 2:
                return ʻ().getBounds().top - ॱˋ();
            default:
                return getPaddingTop();
        }
    }

    private void ॱˎ() {
        if (this.ˊ != null) {
            Drawable background = this.ˊ.getBackground();
            if (background != null) {
                if (cl.ˋ(background)) {
                    background = background.mutate();
                }
                arw.ˏ((ViewGroup) this, this.ˊ, new Rect());
                Rect bounds = background.getBounds();
                if (bounds.left != bounds.right) {
                    Rect rect = new Rect();
                    background.getPadding(rect);
                    background.setBounds(bounds.left - rect.left, bounds.top, (rect.right * 2) + bounds.right, this.ˊ.getBottom());
                }
            }
        }
    }

    private void ॱᐝ() {
        switch (this.ʻॱ) {
            case 1:
                this.ʽॱ = 0;
                return;
            case 2:
                if (this.ᐝˋ == 0) {
                    this.ᐝˋ = this.ॱͺ.getColorForState(getDrawableState(), this.ॱͺ.getDefaultColor());
                    return;
                }
                return;
            default:
                return;
        }
    }

    private void ᐝॱ() {
        if (this.ͺ != null) {
            ॱᐝ();
            if (this.ˊ != null && this.ʻॱ == 2) {
                if (this.ˊ.getBackground() != null) {
                    this.ˊˊ = this.ˊ.getBackground();
                }
                ViewCompat.ˏ(this.ˊ, null);
            }
            if (!(this.ˊ == null || this.ʻॱ != 1 || this.ˊˊ == null)) {
                ViewCompat.ˏ(this.ˊ, this.ˊˊ);
            }
            if (this.ʽॱ > -1 && this.ˋˊ != 0) {
                this.ͺ.setStroke(this.ʽॱ, this.ˋˊ);
            }
            this.ͺ.setCornerRadii(ˋॱ());
            this.ͺ.setColor(this.ˊˋ);
            invalidate();
        }
    }

    public void ʽ() {
        if (this.ˊ != null) {
            Drawable background = this.ˊ.getBackground();
            if (background != null) {
                ʼॱ();
                if (cl.ˋ(background)) {
                    background = background.mutate();
                }
                if (this.ʽ.ʽ()) {
                    background.setColorFilter(bx.ॱ(this.ʽ.ॱॱ(), Mode.SRC_IN));
                } else if (!this.ʼ || this.ʻ == null) {
                    gg.ʽ(background);
                    this.ˊ.refreshDrawableState();
                } else {
                    background.setColorFilter(bx.ॱ(this.ʻ.getCurrentTextColor(), Mode.SRC_IN));
                }
            }
        }
    }

    private void ʼॱ() {
        int i = VERSION.SDK_INT;
        if (i == 21 || i == 22) {
            Drawable background = this.ˊ.getBackground();
            if (background != null && !this.ꜟ) {
                Drawable newDrawable = background.getConstantState().newDrawable();
                if (background instanceof DrawableContainer) {
                    this.ꜟ = arx.ˎ((DrawableContainer) background, newDrawable.getConstantState());
                }
                if (!this.ꜟ) {
                    ViewCompat.ˏ(this.ˊ, newDrawable);
                    this.ꜟ = true;
                    ॱॱ();
                }
            }
        }
    }

    public Parcelable onSaveInstanceState() {
        Parcelable savedState = new SavedState(super.onSaveInstanceState());
        if (this.ʽ.ʽ()) {
            savedState.ˏ = ᐝ();
        }
        savedState.ॱ = this.ˎˏ;
        return savedState;
    }

    protected void onRestoreInstanceState(Parcelable parcelable) {
        if (parcelable instanceof SavedState) {
            SavedState savedState = (SavedState) parcelable;
            super.onRestoreInstanceState(savedState.ˊ());
            setError(savedState.ˏ);
            if (savedState.ॱ) {
                ˋ(true);
            }
            requestLayout();
            return;
        }
        super.onRestoreInstanceState(parcelable);
    }

    protected void dispatchRestoreInstanceState(SparseArray<Parcelable> sparseArray) {
        this.ꓸ = true;
        super.dispatchRestoreInstanceState(sparseArray);
        this.ꓸ = false;
    }

    @Nullable
    public CharSequence ᐝ() {
        return this.ʽ.ˋ() ? this.ʽ.ᐝ() : null;
    }

    public void setHintAnimationEnabled(boolean z) {
        this.ㆍ = z;
    }

    public void draw(Canvas canvas) {
        if (this.ͺ != null) {
            this.ͺ.draw(canvas);
        }
        super.draw(canvas);
        if (this.ˊॱ) {
            this.ˎ.ˊ(canvas);
        }
    }

    protected void onMeasure(int i, int i2) {
        ʾ();
        super.onMeasure(i, i2);
    }

    private void ʾ() {
        if (this.ˊ != null) {
            Drawable[] ˎ;
            if (ʽॱ()) {
                if (this.ˏˏ == null) {
                    this.ˏˏ = (CheckableImageButton) LayoutInflater.from(getContext()).inflate(i.ˊॱ, this.ˋ, false);
                    this.ˏˏ.setImageDrawable(this.ˋᐝ);
                    this.ˏˏ.setContentDescription(this.ˍ);
                    this.ˋ.addView(this.ˏˏ);
                    this.ˏˏ.setOnClickListener(new OnClickListener(this) {
                        final /* synthetic */ TextInputLayout ˎ;

                        {
                            this.ˎ = r1;
                        }

                        public void onClick(View view) {
                            this.ˎ.ˋ(false);
                        }
                    });
                }
                if (this.ˊ != null && ViewCompat.ˋॱ(this.ˊ) <= 0) {
                    this.ˊ.setMinimumHeight(ViewCompat.ˋॱ(this.ˏˏ));
                }
                this.ˏˏ.setVisibility(0);
                this.ˏˏ.setChecked(this.ˎˏ);
                if (this.ˑ == null) {
                    this.ˑ = new ColorDrawable();
                }
                this.ˑ.setBounds(0, 0, this.ˏˏ.getMeasuredWidth(), 1);
                ˎ = TextViewCompat.ˎ(this.ˊ);
                if (ˎ[2] != this.ˑ) {
                    this.ˏˎ = ˎ[2];
                }
                TextViewCompat.ॱ(this.ˊ, ˎ[0], ˎ[1], this.ˑ, ˎ[3]);
                this.ˏˏ.setPadding(this.ˊ.getPaddingLeft(), this.ˊ.getPaddingTop(), this.ˊ.getPaddingRight(), this.ˊ.getPaddingBottom());
                return;
            }
            if (this.ˏˏ != null && this.ˏˏ.getVisibility() == 0) {
                this.ˏˏ.setVisibility(8);
            }
            if (this.ˑ != null) {
                ˎ = TextViewCompat.ˎ(this.ˊ);
                if (ˎ[2] == this.ˑ) {
                    TextViewCompat.ॱ(this.ˊ, ˎ[0], ˎ[1], this.ˏˎ, ˎ[3]);
                    this.ˑ = null;
                }
            }
        }
    }

    public void setPasswordVisibilityToggleDrawable(@DrawableRes int i) {
        setPasswordVisibilityToggleDrawable(i != 0 ? ar.ˋ(getContext(), i) : null);
    }

    public void setPasswordVisibilityToggleDrawable(@Nullable Drawable drawable) {
        this.ˋᐝ = drawable;
        if (this.ˏˏ != null) {
            this.ˏˏ.setImageDrawable(drawable);
        }
    }

    public void setPasswordVisibilityToggleContentDescription(@StringRes int i) {
        setPasswordVisibilityToggleContentDescription(i != 0 ? getResources().getText(i) : null);
    }

    public void setPasswordVisibilityToggleContentDescription(@Nullable CharSequence charSequence) {
        this.ˍ = charSequence;
        if (this.ˏˏ != null) {
            this.ˏˏ.setContentDescription(charSequence);
        }
    }

    public void setPasswordVisibilityToggleEnabled(boolean z) {
        if (this.ˋˋ != z) {
            this.ˋˋ = z;
            if (!(z || !this.ˎˏ || this.ˊ == null)) {
                this.ˊ.setTransformationMethod(PasswordTransformationMethod.getInstance());
            }
            this.ˎˏ = false;
            ʾ();
        }
    }

    public void setPasswordVisibilityToggleTintList(@Nullable ColorStateList colorStateList) {
        this.ͺॱ = colorStateList;
        this.ـ = true;
        ˈ();
    }

    public void setPasswordVisibilityToggleTintMode(@Nullable Mode mode) {
        this.ॱʼ = mode;
        this.ॱʽ = true;
        ˈ();
    }

    public void ˋ(boolean z) {
        if (this.ˋˋ) {
            int selectionEnd = this.ˊ.getSelectionEnd();
            if (ʿ()) {
                this.ˊ.setTransformationMethod(null);
                this.ˎˏ = true;
            } else {
                this.ˊ.setTransformationMethod(PasswordTransformationMethod.getInstance());
                this.ˎˏ = false;
            }
            this.ˏˏ.setChecked(this.ˎˏ);
            if (z) {
                this.ˏˏ.jumpDrawablesToCurrentState();
            }
            this.ˊ.setSelection(selectionEnd);
        }
    }

    public void setTextInputAccessibilityDelegate(b bVar) {
        if (this.ˊ != null) {
            ViewCompat.ˏ(this.ˊ, bVar);
        }
    }

    private boolean ʿ() {
        return this.ˊ != null && (this.ˊ.getTransformationMethod() instanceof PasswordTransformationMethod);
    }

    private boolean ʽॱ() {
        return this.ˋˋ && (ʿ() || this.ˎˏ);
    }

    private void ˈ() {
        if (this.ˋᐝ == null) {
            return;
        }
        if (this.ـ || this.ॱʽ) {
            this.ˋᐝ = gg.ʻ(this.ˋᐝ).mutate();
            if (this.ـ) {
                gg.ॱ(this.ˋᐝ, this.ͺॱ);
            }
            if (this.ॱʽ) {
                gg.ˋ(this.ˋᐝ, this.ॱʼ);
            }
            if (this.ˏˏ != null && this.ˏˏ.getDrawable() != this.ˋᐝ) {
                this.ˏˏ.setImageDrawable(this.ˋᐝ);
            }
        }
    }

    protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
        super.onLayout(z, i, i2, i3, i4);
        if (this.ͺ != null) {
            ˊॱ();
        }
        if (this.ˊॱ && this.ˊ != null) {
            Rect rect = this.ˉ;
            arw.ˏ((ViewGroup) this, this.ˊ, rect);
            int compoundPaddingLeft = rect.left + this.ˊ.getCompoundPaddingLeft();
            int compoundPaddingRight = rect.right - this.ˊ.getCompoundPaddingRight();
            int ʻॱ = ʻॱ();
            this.ˎ.ॱ(compoundPaddingLeft, rect.top + this.ˊ.getCompoundPaddingTop(), compoundPaddingRight, rect.bottom - this.ˊ.getCompoundPaddingBottom());
            this.ˎ.ˎ(compoundPaddingLeft, ʻॱ, compoundPaddingRight, (i4 - i2) - getPaddingBottom());
            this.ˎ.ॱॱ();
            if (ˊˊ() && !this.ᐝˊ) {
                ˋˊ();
            }
        }
    }

    private void ˎ(boolean z) {
        if (this.ꜞ != null && this.ꜞ.isRunning()) {
            this.ꜞ.cancel();
        }
        if (z && this.ㆍ) {
            ˎ(1.0f);
        } else {
            this.ˎ.ˏ(1.0f);
        }
        this.ᐝˊ = false;
        if (ˊˊ()) {
            ˋˊ();
        }
    }

    private boolean ˊˊ() {
        return this.ˊॱ && !TextUtils.isEmpty(this.ॱˊ) && (this.ͺ instanceof asv);
    }

    private void ˋˊ() {
        if (ˊˊ()) {
            RectF rectF = this.ˎˎ;
            this.ˎ.ॱ(rectF);
            ˎ(rectF);
            ((asv) this.ͺ).ॱ(rectF);
        }
    }

    private void ˊᐝ() {
        if (ˊˊ()) {
            ((asv) this.ͺ).ˎ();
        }
    }

    private void ˎ(RectF rectF) {
        rectF.left -= (float) this.ᐝॱ;
        rectF.top -= (float) this.ᐝॱ;
        rectF.right += (float) this.ᐝॱ;
        rectF.bottom += (float) this.ᐝॱ;
    }

    protected void drawableStateChanged() {
        boolean z = true;
        if (!this.ᶥ) {
            int ˋ;
            this.ᶥ = true;
            super.drawableStateChanged();
            int[] drawableState = getDrawableState();
            if (!(ViewCompat.ˊᐝ(this) && isEnabled())) {
                z = false;
            }
            ॱ(z);
            ʽ();
            ˊॱ();
            ʼ();
            if (this.ˎ != null) {
                ˋ = this.ˎ.ˋ(drawableState) | 0;
            } else {
                ˋ = 0;
            }
            if (ˋ != 0) {
                invalidate();
            }
            this.ᶥ = false;
        }
    }

    public void ʼ() {
        Object obj = 1;
        if (this.ͺ != null && this.ʻॱ != 0) {
            Object obj2 = (this.ˊ == null || !this.ˊ.hasFocus()) ? null : 1;
            if (this.ˊ == null || !this.ˊ.isHovered()) {
                obj = null;
            }
            if (this.ʻॱ == 2) {
                if (!isEnabled()) {
                    this.ˋˊ = this.ᐝᐝ;
                } else if (this.ʽ.ʽ()) {
                    this.ˋˊ = this.ʽ.ॱॱ();
                } else if (this.ʼ && this.ʻ != null) {
                    this.ˋˊ = this.ʻ.getCurrentTextColor();
                } else if (obj2 != null) {
                    this.ˋˊ = this.ᐝˋ;
                } else if (obj != null) {
                    this.ˋˊ = this.ᐨ;
                } else {
                    this.ˋˊ = this.ᐧ;
                }
                if (!(obj == null && obj2 == null) && isEnabled()) {
                    this.ʽॱ = this.ˊᐝ;
                } else {
                    this.ʽॱ = this.ʼॱ;
                }
                ᐝॱ();
            }
        }
    }

    private void ˏ(boolean z) {
        if (this.ꜞ != null && this.ꜞ.isRunning()) {
            this.ꜞ.cancel();
        }
        if (z && this.ㆍ) {
            ˎ(0.0f);
        } else {
            this.ˎ.ˏ(0.0f);
        }
        if (ˊˊ() && ((asv) this.ͺ).ॱ()) {
            ˊᐝ();
        }
        this.ᐝˊ = true;
    }

    @VisibleForTesting
    void ˎ(float f) {
        if (this.ˎ.ˊ() != f) {
            if (this.ꜞ == null) {
                this.ꜞ = new ValueAnimator();
                this.ꜞ.setInterpolator(aqv.ॱ);
                this.ꜞ.setDuration(167);
                this.ꜞ.addUpdateListener(new AnimatorUpdateListener(this) {
                    final /* synthetic */ TextInputLayout ˎ;

                    {
                        this.ˎ = r1;
                    }

                    public void onAnimationUpdate(ValueAnimator valueAnimator) {
                        this.ˎ.ˎ.ˏ(((Float) valueAnimator.getAnimatedValue()).floatValue());
                    }
                });
            }
            this.ꜞ.setFloatValues(new float[]{this.ˎ.ˊ(), f});
            this.ꜞ.start();
        }
    }
}
